package com.ruoyi.antchain.controller;

import com.ruoyi.antchain.service.VoteChainService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 投票
 *
 * @author deng
 * @date 2020/11/13 13:34
 */
@Controller
@RequestMapping("/anti/vote")
public class VoteChainController {
    private String prefix = "antchain/vote";

    @Autowired
    private VoteChainService voteChainService;

    @GetMapping("/getVote")
    public String getVote(ModelMap mmap) {
        return prefix + "/vote";

    }

    /**
     * 投票
     *
     * @param lan
     * @return
     */
    @RequestMapping("/add")
    @ResponseBody
    public AjaxResult add(@RequestParam("lan") Integer[] lan) {
        return voteChainService.vote(lan);
    }

    /**
     * 票数
     *
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list() {
        return voteChainService.list();
    }



    @GetMapping("/table")
    public String table(ModelMap mmap) {
        return prefix + "/table";

    }

}
